<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition>
	<p:panel id="userInfoPanel" header="${msgs.pleaseEditYourInfo}"
		style="width:100%;">
		<f:event listener="#{locationController.init}"
			type="preRenderComponent"></f:event>
		<h:panelGrid columns="2" style="width:100%;">
			<h:outputText value="#{msgs.preferedLanguage}*" />
			<p:selectOneRadio value="#{userModel.authenticatedUser.language}">
				<f:selectItems value="#{userModel.availableLanguages}"
					var="language" itemValue="#{language}"
					itemLabel="#{language.label}"></f:selectItems>
				<p:ajax event="change" listener="#{userController.languageChanged}"
					update="userInfoPanel"></p:ajax>
			</p:selectOneRadio>
			<h:outputText value="#{msgs.email}*" />
			<h:panelGrid columns="2">
				<p:inputText id="email" value="#{userModel.authenticatedUser.email}"
					validator="#{validator.validateEmail}" required="true"
					requiredMessage="#{msgs.requiredFieldMessage}">
					<f:attribute name="user" value="#{userModel.authenticatedUser}" />
				</p:inputText>
				<p:message for="email" showSummary="false"></p:message>
			</h:panelGrid>
			<h:outputText value="#{msgs.telephone}*" />
			<h:panelGrid columns="2">
				<p:inputMask id="telephone"
					value="#{userModel.authenticatedUser.telephone}"
					mask="(999)999-9999" validator="#{validator.validateTelephone}"
					required="true" requiredMessage="#{msgs.requiredFieldMessage}">
					<f:attribute name="user" value="#{userModel.authenticatedUser}" />
				</p:inputMask>
				<p:message for="telephone" showSummary="false"></p:message>
			</h:panelGrid>
			<h:outputText value="#{msgs.pickUpLocation}*:" />

			<ui:remove>
				<h:panelGrid columns="2"
					rendered="#{!userModel.authenticatedUser.isHaveUndeliveredOrder}">
					<h:panelGrid columns="2">
						<p:selectOneMenu id="locationSelectMenu"
							value="#{userModel.authenticatedUser.dropOffLocation}"
							required="true" requiredMessage="#{msgs.requiredFieldMessage}"
							converter="#{locationConverter}"
							validator="#{validator.validateDropOffLocation}">
							<f:selectItems value="#{locationModel.list}" var="location"
								itemLabel="#{location.address} (#{location.postCode})"
								itemValue="#{location}" />
						</p:selectOneMenu>
						<p:message for="locationSelectMenu" showSummary="false" />
					</h:panelGrid>
					<p:commandButton value="#{msgs.viewMap}"
						oncomplete="pickupInfoMapDlg.show()" update=":dialogForm"
						ajax="true"></p:commandButton>
				</h:panelGrid>
			</ui:remove>

			<h:outputText value="#{msgs.youHaveUndeliveredOrder}"
				rendered="#{userModel.authenticatedUser.isHaveUndeliveredOrder}"></h:outputText>


			<h:panelGrid id="pickupLocationPanelGrid" columns="2" rendered="#{!userModel.authenticatedUser.isHaveUndeliveredOrder}">
				<h:panelGrid columns="3">
					<h:panelGroup>
						<h:outputText
							value="#{userModel.authenticatedUser.dropOffLocation.name}, "></h:outputText>
						<h:outputText
							value="#{userModel.authenticatedUser.dropOffLocation.address}, "></h:outputText>

						<h:outputText
							value="#{userModel.authenticatedUser.dropOffLocation.postCode} "></h:outputText>
					</h:panelGroup>

					<p:commandButton value="#{msgs.clickToChoosePickupLocation}"
						oncomplete="userInfoChooseLocationMapDlg.show()" ajax="true"></p:commandButton>
				</h:panelGrid>
			</h:panelGrid>

			<h:outputText value="#{msgs.title}" />
			<p:selectOneMenu value="#{userModel.authenticatedUser.title}">
				<f:selectItems value="#{userModel.availableTitles}" var="titles"
					itemValue="#{title}" itemLabel="#{titles.label}"></f:selectItems>
			</p:selectOneMenu>
			<h:outputText value="#{msgs.lastName}*" />
			<h:panelGrid columns="2">
				<p:inputText id="lastName"
					value="#{userModel.authenticatedUser.lastName}" required="true"
					requiredMessage="#{msgs.requiredFieldMessage}" />
				<p:message for="lastName" showSummary="false"></p:message>
			</h:panelGrid>
			<h:outputText value="#{msgs.firstName}*" />
			<h:panelGrid columns="2">
				<p:inputText id="firstName"
					value="#{userModel.authenticatedUser.firstName}" required="true"
					requiredMessage="#{msgs.requiredFieldMessage}" />
				<p:message for="firstName" showSummary="false" />
			</h:panelGrid>
			<h:outputText value="#{msgs.address}*" />
			<h:panelGrid columns="2" style="width:100%">
				<p:inputText id="address"
					value="#{userModel.authenticatedUser.address}" required="true"
					requiredMessage="#{msgs.requiredFieldMessage}" style="width:100%" />
				<p:message for="address" showSummary="false" style="width:100%"></p:message>
			</h:panelGrid>
			<h:outputText value="#{msgs.passwordQuestion}*" />
			<h:panelGrid columns="2">
				<p:selectOneMenu id="passwordQuestion"
					value="#{userModel.authenticatedUser.passwordQuestion}"
					required="true" requiredMessage="#{msgs.requiredFieldMessage}"
					editable="true">
					<f:selectItem itemLabel="#{msgs.pleaseChoosePasswordQuestion}"
						itemValue=""></f:selectItem>
					<f:selectItems
						value="#{userModel.authenticatedUser.passwordQuestionList}"
						var="questionList" itemLabel="#{questionList}"
						itemValue="#{questionList}" />
				</p:selectOneMenu>
				<p:message for="passwordQuestion" showSummary="false"></p:message>
			</h:panelGrid>
			<h:outputText value="#{msgs.passwordAnswer}*" />
			<h:panelGrid columns="2">
				<p:inputText id="passwordAnswer"
					value="#{userModel.authenticatedUser.passwordAnswer}"
					required="true" requiredMessage="#{msgs.requiredFieldMessage}" />
				<p:message for="passwordAnswer" showSummary="false" />
			</h:panelGrid>
			<h:outputText value="#{msgs.mobilePhone}" />
			<p:inputMask value="#{userModel.authenticatedUser.mobilePhone}"
				mask="(999)999-9999" />
			<h:inputHidden />
			<p:panelGrid columns="1">
				<p:selectBooleanCheckbox itemLabel="#{msgs.emailMeOrderStatus}"
					value="#{userModel.authenticatedUser.isEmailOrderStatus}">
					<p:ajax event="change" update=":centerForm" process="@this"></p:ajax>
				</p:selectBooleanCheckbox>
				<h:panelGrid columns="2"
					rendered="#{userModel.authenticatedUser.isEmailOrderStatus}">
					<p:selectBooleanCheckbox itemLabel="#{msgs.ORDER_STATUS_CONFIRMED}"
						value="#{userModel.authenticatedUser.isEmailStatusConfirm}" />
					<p:selectBooleanCheckbox itemLabel="#{msgs.ORDER_STATUS_PREPARED}"
						value="#{userModel.authenticatedUser.isEmailStatusPrepare}" />
					<p:selectBooleanCheckbox itemLabel="#{msgs.ORDER_STATUS_DELIVERED}"
						value="#{userModel.authenticatedUser.isEmailStatusDeliver}" />
					<p:selectBooleanCheckbox itemLabel="#{msgs.ORDER_STATUS_PAID}"
						value="#{userModel.authenticatedUser.isEmailStatusPay}" />
					<p:selectBooleanCheckbox itemLabel="#{msgs.ORDER_STATUS_CANCELED}"
						value="#{userModel.authenticatedUser.isEmailStatusCancel}" />
				</h:panelGrid>
			</p:panelGrid>
			<h:inputHidden />
			<p:commandButton value="#{msgs.submit}" type="submit"
				style="float:left"
				action="#{userController.storeAuthenticatedUserInfo}"></p:commandButton>
		</h:panelGrid>
	</p:panel>
</ui:composition>

</html>